package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.constant.enums.NormalAuditActionStatusEnum;
import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.SpSecurityPunishmentCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.SpSecurityPunishmentResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.SpSecurityPunishmentUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.SpSecurityPunishmentEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface SpSecurityPunishmentConvert {
    SpSecurityPunishmentConvert INSTANCE = Mappers.getMapper(SpSecurityPunishmentConvert.class);

    SpSecurityPunishmentResultDTO convert(SpSecurityPunishmentEntity s);

    SpSecurityPunishmentEntity create(SpSecurityPunishmentCreateDTO s);

    SpSecurityPunishmentEntity update(SpSecurityPunishmentUpdateDTO s);

    default SpSecurityPunishmentEntity create(SpSecurityPunishmentCreateDTO s, Long tenantId, NormalAuditActionStatusEnum action) {
        SpSecurityPunishmentEntity entity = create(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        entity.setPreAction(action);
        return entity;
    }
}
